#ifndef DOWNLOADTABLEMODEL_H
#define DOWNLOADTABLEMODEL_H
#include <QSqlRelationalTableModel>
#include <QVector>
#include <QMap>
#include <QSqlQuery>

class DownloadTableModel:
        public QSqlRelationalTableModel
{
    Q_OBJECT
    QMap<int, int> idToRow;
public:
    DownloadTableModel(QObject * parent, QSqlDatabase *db);
public slots:
    void addDownload(const QString &folder,
                     const QString &fileName,
                     const QString &URL,
                     int priority);
    void removeDownload(const QModelIndex &index);
    void modify(int id, int column, QVariant value);

signals:
    void addTask(int id, const QString &fileName, const QString &URL, int priority);
    void removeTask(int id);
private:
    void rebuildCache();
};

#endif // DOWNLOADTABLEMODEL_H
